<template>
<div>
     <el-form-item label="代码" prop="html">
            <el-input
              v-model="formData.html"
              v-on:change="update"
              autocomplete="off"
              type="textarea"
              :autosize="{ minRows: 8, maxRows: 15 }"
              placeholder="请输入代码"
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
       
          <!--  -->
          <el-form-item label="点击链接" prop="linkurl">
            <el-input
              v-model="formData.linkurl"
              v-on:change="update"
              autocomplete="off"
              placeholder="请输入点击链接"
              :style="{ width: '100%' }"
            ></el-input>
          </el-form-item>
          <el-form-item label="上传图片" prop="images" >
          <el-upload v-loading="flashpicLoading"
                    class="upload-demo"
                    action="index.php?module=API&method=AdsPlace.transfile&format=json"
                    :show-file-list="false"
                    :on-success="handleUploadChange"
                    :before-upload="beforeUpload"
                    :on-error="onUploadError"
                     accept=".jpg,image/jpeg,.png,image/png,.gif"
                    >
                    <el-button type="primary" icon="el-icon-upload" size="mini"
                        >点击上传</el-button
                    >
                    <label >支持jpg、gif、png,格式</label>
                    <!-- <p class="in_pictureURL">使用网络图片URL</p> -->
                    </el-upload>
                    <!-- 上传图片结果显示url -->
            <div v-if="formData.attachments" class="word-break">
                      <a> {{formData.attachments}} </a></div>
          </el-form-item>
</div>
</template>

<script>
//   <!-- 漂浮弹窗的html广告 -->
export default {
  components: { },
  props: ['formData'],
  data: function(){
      return {
             
     // flashpic: undefined, //临时图片保存
      flashpicLoading: false, //上传的loading 等待；
      loading:false,
 

      }
  },
   methods: {
    update( ) {
      this.$emit('htmlcodechange', this.formData)
    },
        // 上传备用图片
    handleUploadChange(response, file, fileList){
        //this.flashpic = response.data;
        this.formData.attachments = response.data;
        this.flashpicLoading = false;
        this.update();
    },
    beforeUpload(file ){
      this.flashpicLoading=true;
    },
    onUploadError(err, file, fileList){
      this.flashpicLoading = false;
      this.$message({message:"上传失败", type:"error"})
    },
   }
}
</script>
